package kkk;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import robocode.control.testing.RobotTestBed;

/**
 * Tests Strafers proportional fire method.
 * 
 * @author Kyle Kakinami
 * 
 */
public class TestStraferPower extends RobotTestBed {
  /** create an instance of Strafer. **/
  Strafer robot = new Strafer();

  // Find the max possible distance for the given battlefield.
  double wSquared = Math.pow(width, 2);
  double hSquared = Math.pow(height, 2);
  double maxDistance = Math.sqrt(wSquared + hSquared) + 1;

  /**
   * Tests to see that Strafer proportionalFire returns the expected value.
   * 
   */
  @Test
  public void run() {
    // Checks that at max distance power is 0.1.
    assertEquals("Check max distance power", robot.proportionalFire(maxDistance, maxDistance), 0.1,
        0.1);
    // Checks that at half distance, power is 1.5.
    assertEquals("Check half max distance power",
        robot.proportionalFire(maxDistance / 2, maxDistance),
        3.0 * (1 - (maxDistance / 2 / maxDistance)), 0.1);

  }

  @Override
  public String getRobotNames() {
    // TODO Auto-generated method stub
    return null;
  }
}
